const fs = require("fs");
const path = require("path");

function readFile(url) {
  const currDataPath = path.resolve(__dirname, '../DataHome') + url + "/index.json"
  return new Promise((resolve, reject) => {
    fs.readFile(
      currDataPath,
      "utf8",
      (err, data) => {
        if (err) {
          console.log(
            "err",
            err,
            `url: ${currDataPath}`
          );
          reject(`err ${err}可以创建`);
          return err;
        }
        console.log("data读取成功", JSON.parse(data));
        return resolve(data);
      }
    );
  });
}

module.exports = readFile;
